﻿using System.Web.Mvc;
using System.Web.Routing;

namespace EssenceFeed.Core.Helpers
{
    /// <summary>
    /// ImageLinkExtensions
    /// </summary>
    public static class ImageLinkExtensions
    {
        /*
        /// <summary>  
        /// A Simple ActionLink Image  
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="actionName">name of the action in controller</param>  
        /// <param name="imgUrl">url of the image</param>  
        /// <param name="alt">alt text of the image</param>  
        /// <returns></returns>  
        public static string ImageLink(this HtmlHelper helper, string actionName, string imgUrl, string alt)
        {
            return ImageLink(helper, actionName, imgUrl, alt, null, null, null);
        }

        /// <summary>  
        /// A Simple ActionLink Image  
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="actionName">name of the action in controller</param>  
        /// <param name="imgUrl">url of the image</param>  
        /// <param name="alt">alt text of the image</param>
        /// <param name="routeValues"></param>
        /// <returns></returns>  
        public static string ImageLink(this HtmlHelper helper, string actionName, string imgUrl, string alt,
                                       object routeValues)
        {
            return ImageLink(helper, actionName, imgUrl, alt, routeValues, null, null);
        }
        /*
        /// <summary>  
        /// A Simple ActionLink Image  
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="actioNName">name of the action in controller</param>  
        /// <param name="imgUrl">url of the image</param>  
        /// <param name="alt">alt text of the image</param>
        /// <param name="routeValues"></param>
        /// <param name="linkHtmlAttributes">attributes for the link</param>  
        /// <param name="imageHtmlAttributes">attributes for the image</param>  
        /// <returns></returns>  
        public static string ImageLink(this HtmlHelper helper, string actioNName, string imgUrl, string alt,
                                       object routeValues, object linkHtmlAttributes, object imageHtmlAttributes)
        {
            var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
            string url = urlHelper.Action(actioNName, routeValues);
            //Create the link  
            var linkTagBuilder = new TagBuilder("a");
            linkTagBuilder.MergeAttribute("href", url);
            linkTagBuilder.MergeAttributes(new RouteValueDictionary(linkHtmlAttributes));
            //Create image  
            var imageTagBuilder = new TagBuilder("img");
            imageTagBuilder.MergeAttribute("src", urlHelper.Content(imgUrl));
            imageTagBuilder.MergeAttribute("alt", urlHelper.Content(alt));
            imageTagBuilder.MergeAttributes(new RouteValueDictionary(imageHtmlAttributes));

            //Add image to link  
            linkTagBuilder.InnerHtml = imageTagBuilder.ToString(TagRenderMode.SelfClosing);
            return linkTagBuilder.ToString();
        }
         * */
    }
}

//<%= Html.ImageLink("EditCompanyPage", "../../Content/Images/carbon/edit.png", "copyright AMDi", new { id = 0 }) %> 
